import React, { Component } from 'react'

export default class Child extends React.PureComponent{
// export default class Child extends Component {
  constructor() {
    super()
    console.log('子组件-constructor')
  }
  componentDidMount() {
    console.log('子组件-componentDidMount')
  }
  componentDidUpdate() {
    console.log('子组件-componentDidUpdate')
  }
  componentWillUnmount() {
    console.log('子组件-componentWillUnmount')
  }
  // shouldComponentUpdate(nextProps, nextState) {
  //   console.log('子组件-shouldComponentUpdate', nextProps, this.props)
  //   if(nextProps.msg === this.props.msg) { // 说明传递给子组件的 props 没有发生改变
  //     return false
  //   } else {
  //     return true
  //   }
  // }
  render() {
    console.log('子组件-render')
    const {msg} = this.props
    return (
      <div className='child'>
        <p>子组件获取的父组件数据：{msg}</p>
      </div>
    )
  }
}
